package design;

import design.forkjoin.Callable6;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future;

public class ForkJoinTest5 {
    public static void main(String[] args) {
        List list = new ArrayList<>();
        list.add(new Callable6("A"));
        list.add(new Callable6("B"));
        list.add(new Callable6("C"));
        list.add(new Callable6("D"));
        list.add(new Callable6("E"));
        ForkJoinPool pool = new ForkJoinPool();
        List<Future<String>> listFuture = pool.invokeAll(list);
        for (Future<String> f : listFuture) {
            try {
                System.out.println(f.get());
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }
        }
    }
}
